package com.king01.controller;

import com.king01.annotation.LogAnnotation;
import com.king01.entity.Branch;
import com.king01.entity.Staff;
import com.king01.service.BranchService;
import com.king01.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ：lqs
 * @date ：Created in 2023/9/27 9:55
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/brand")
public class BranchController {

    @Autowired
    private BranchService branchService;
    //查询店铺表的全部数据
    @RequestMapping("/info")
    public Result info(){
        Result result = branchService.allBranch();
        return result;
    }
    //查询店铺表的全部数据
    @RequestMapping("/info2")
    @LogAnnotation
    public Result info2(){
        Result result = branchService.allBranch2();
        return result;
    }


    @RequestMapping("/list")
    @LogAnnotation
    public Result list() {
        Result result = branchService.selectAll();
        return result;
    }
    //店铺信息
    @RequestMapping ("/branchInfo")
    public Result selestBranchInfo() {
        Result result = branchService.selectAllBranchAndStaff();
        return result;
    }
    @RequestMapping ("/store")
    public PageBean<Branch> selestBranchInfo(Integer currentPage, Integer pageSize, @RequestBody BranchVo branchVo) {
        PageBean<Branch> result = branchService.selectAllBranchAndStaff(currentPage, pageSize,branchVo);
        System.out.println("-----"+result);
        return result;
    }
    //模糊查询
    @RequestMapping("/query")
    public Result queryselestBranchInfoByBranchname(@RequestBody Branch branchname){
        Result result = branchService.queryBranchInfoBybranchname(branchname);
        return result;
    }
    //添加新的店铺信息
    @RequestMapping ("/insert")
    public Integer insertNewBranch(@RequestBody Branch branch){
        Integer integer = branchService.insertNewBranch(branch);
        return integer;

    }
    //修改
    @RequestMapping ("/update")
    public Integer UpdateBranch(@RequestBody Branch branch) {
//        System.out.println("1313131313 "+branch );
        Integer integer = branchService.UpdateBranch(branch);
        return integer;

    }
    @RequestMapping("/adjust")
    public Result adjust(@RequestBody Branch branch){
        Result result = branchService.adjustBranch(branch);
        return result;
    }


    @RequestMapping("/diao")
    public Integer upBranch(@RequestBody Staff02vo staff02vo){
        Integer integer1 = branchService.upBranch(staff02vo);
        Integer integer = branchService.upStaff(staff02vo);
        return integer;
    }

    @RequestMapping("/getAll")
    public List<Staff> getAll(){
        List<Staff> list = branchService.selectAll2();
        return list;
    }

    @RequestMapping("/updateAll")
    public Integer updateAll(@RequestBody Staff staff){
        Integer integer = branchService.updateDate(staff);
        Integer integer1 = branchService.updateStaff(staff);
        return integer1;
    }

    @RequestMapping("/dept")
    public Result dept(Integer branchid){
        Result result = branchService.selectDeptName(branchid);
        return result;
    }
}

